<template>
  <div class="match-index position-relative">
    <div class="text-center">
      <h3 class="text-center" v-text="match.name"></h3>
      <div :style="{ width: '429px', margin: '0 auto', fontSize: '18px' }">
        <div v-if="user" class="user">
          <span>当前账号：</span>
          <span class="name">{{ user.phonenum ? user.phonenum : user.gid }}</span>
          <span @click="click" class="name2 cu">
            <el-icon color="#ffffff" :size="20">
              <Switch />
            </el-icon>
          </span>
        </div>
        <div v-else class="user">
          <span>当前账号：</span>
          <span @click="click" class="name">登录</span>
        </div>
      </div>
      <div>
        <div class="text-center">
          <button :disabled="!!isnot.err" :title="isnot.msg" class="bt btn" @click="gotomatch">
            进入测评
          </button>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { Switch } from '@element-plus/icons-vue';
import { ElMessage } from "element-plus";
import {
  computed,
  inject,
  onDeactivated,
  ref,
} from "vue";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import { Apimatchuserquestion } from "../../../api";
import { Storekey } from "../../../interface";
import Studycodemodel from "../../../mysql_interface/studycodemodel";
import Aircraft from "../../../threecanvas/aircraft";
const router = useRouter();
const store = useStore(Storekey);
const headnavdialogVisible = inject("headnavdialogVisible", () => { });

const p = defineProps<{ time: Record<string, any>, match: Studycodemodel.Iactivity, getm: Function, matchuser: Apimatchuserquestion[], start: Function, isnot: { err: number; msg: string }, testid: string }>()

const user = computed(() => {
  return store.getters.getuser;
});
const aircraft = ref<Aircraft>();
onDeactivated(() => {
  aircraft.value?.clearanimation();
});
function gotomatch() {
  if (p.isnot.err) {
    ElMessage.warning(p.isnot.msg);
    return;
  }
  router.push({
    name: "测评答题",
    params: {
      index: 0,
    },
    query: {
      testid: p.testid,
    },
  });
}
function click() {
  // 登录
  headnavdialogVisible();
}
</script>
<style scoped>
.text-center1 {
  width: 960px;
  height: 528px;
}

.match-index {
  min-height: 75vh;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url(../../../assets/image/match-bg.webp);
  background-repeat: no-repeat;
  background-size: cover;
  color: #fff;
  font-family: Microsoft YaHei;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

h3 {
  font-size: 32px;
  margin-bottom: 50px;
  font-weight: bold;
}

.time {
  margin-bottom: 20px;
}

.user {
  line-height: 26px;
  margin-bottom: 25px;
}

.user .el-avatar {
  transform: translateY(6px);
}

.name {
  height: 26px;
  background: var(--color-cheng);
  border-radius: 13px;
  display: inline-block;
  line-height: 26px;
  padding-left: 12px;
  padding-right: 12px;
  margin-left: 10px;
  margin-right: 10px;
  color: #fff;
}

.name2 {
  height: 26px;
  background: #434343;
  border-radius: 13px;
  display: inline-block;
  font-size: 16px;
  line-height: 26px;
  padding-left: 12px;
  padding-right: 12px;
  margin-left: 10px;
  margin-right: 10px;
}

.times {
  margin-top: 10px;
  margin-bottom: 48px;

  line-height: 24px;
}

.times span {
  display: inline-block;
  height: 24px;
  background: #434343;
  border-radius: 2px;
  text-align: center;
  color: #fff;
  padding-left: 4px;
  padding-right: 4px;
}

.bt {
  width: 182px;
  height: 50px;
  background: var(--color-cheng);
  border-radius: 25px;
  font-size: 24px;
  font-family: PingFang SC;
  color: #fff;
}

.bt:hover {
  color: #ffffff;
}

.yuedu {
  margin-top: 12px;
  font-size: 14px;
  font-weight: 400;
}

.yuedu a {
  font-weight: 800;
  color: #434343;
}

#aicr {
  position: fixed;
  height: 100vh;
  width: 100vw;
  z-index: -1;
  background: linear-gradient(#e4e0ba, #f7d9aa);
}
</style>
